home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / AppsToGo / pbClock / TRootObj.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  3.9 KB  |  147 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        TRootObj.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1992 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* You may incorporate this sample code into your applications without
  12. ** restriction, though the sample code has been provided "AS IS" and the
  13. ** responsibility for its operation is 100% yours.  However, what you are
  14. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  15. ** after having made changes. If you're going to re-distribute the source,
  16. ** we require that you make it clear in the source that the code was
  17. ** descended from Apple Sample Code, but that you've made changes. */
  18.  
  19. /* See the files "=How to write your app" and "=Using TreeObj.c" for information
  20. ** on this function. */
  21.  
  22. /* This file isn't really used for much here.  The whole hierarchical document usage of
  23. ** AppWannabe is very limited.  This file is here so that AppWannabe can be converted
  24. ** into an application that does use the hierarchical document architecture.  AppWannabe
  25. ** is all set up to start using it.  This is convenient, as it allows there to be an
  26. ** initial document type. */
  27.  
  28.  
  29.  
  30. /*****************************************************************************/
  31.  
  32.  
  33.  
  34. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  35. #include "App.protos.h"        /* Get the prototypes for application.            */
  36.  
  37. #ifndef __OSEVENTS__
  38. #include <OSEvents.h>
  39. #endif
  40.  
  41. #ifndef __OSUTILS__
  42. #include <OSUtils.h>
  43. #endif
  44.  
  45. #ifndef __QUICKDRAW__
  46. #include <Quickdraw.h>
  47. #endif
  48.  
  49. #ifndef __UTILITIES__
  50. #include "Utilities.h"
  51. #endif
  52.  
  53.  
  54.  
  55. /*****************************************************************************/
  56.  
  57.  
  58.  
  59. static RootObjPeek    *gMWERKSDebug;
  60.     /* For Metroweks debugging of AppsToGo "objects", you need an instance of the
  61.     ** same type you wish to view it in the debugger.  Now we have an instance. */
  62.  
  63.  
  64.  
  65. /*****************************************************************************/
  66. /*****************************************************************************/
  67.  
  68. #ifdef applec
  69. #pragma segment TRootObj
  70. #endif
  71.  
  72. /*****************************************************************************/
  73. /*****************************************************************************/
  74.  
  75.  
  76.  
  77. long    TRootObj(TreeObjHndl hndl, short message, long data)
  78. {
  79.     short    fileRefNum;
  80.     OSErr    err;
  81. #if VH_VERSION
  82.     char    *cptr;
  83. #endif
  84.  
  85.     switch (message) {
  86.         case INITMESSAGE:
  87.             mDerefRoot(hndl)->timeControl[0] = 5 * 60 * 60;
  88.             mDerefRoot(hndl)->timeControl[1] = 0;
  89.             mDerefRoot(hndl)->timeControl[2] = 0;
  90.             mDerefRoot(hndl)->timeControl[3] = 5 * 60 * 60;
  91.             mDerefRoot(hndl)->timeControl[4] = 0;
  92.             mDerefRoot(hndl)->timeControl[5] = 0;
  93.             mDerefRoot(hndl)->numMovesInTimeControl[0] = 0;
  94.             mDerefRoot(hndl)->numMovesInTimeControl[1] = 0;
  95.             mDerefRoot(hndl)->numMovesInTimeControl[2] = 0;
  96.             mDerefRoot(hndl)->timeRemaining[0] = mDerefRoot(hndl)->timeControl[0];
  97.             mDerefRoot(hndl)->timeRemaining[1] = mDerefRoot(hndl)->timeControl[0];
  98.             mDerefRoot(hndl)->numMoves[0] = 0;
  99.             mDerefRoot(hndl)->numMoves[1] = 0;
  100.             mDerefRoot(hndl)->rightStart  = -1;
  101.                 /* •••• Initialize the new object to default values.  Note that the
  102.                 **        values are pre-initialized to 0 before this is called.  I
  103.                 **        am setting some fields to zero anyway for completeness and
  104.                 **        readability. */
  105.             break;
  106.  
  107.         case FREADMESSAGE:
  108.             fileRefNum = data;
  109.             err = ReadTreeObjData(hndl, fileRefNum);
  110.             mDerefRoot(hndl)->rightStart = -1;
  111.             return(err);
  112.             break;
  113.  
  114.         case FWRITEMESSAGE:
  115.             fileRefNum = data;
  116.             return(WriteTreeObjData(hndl, fileRefNum));
  117.             break;
  118.  
  119.         case HREADMESSAGE:
  120.             return(HReadTreeObjData(hndl, (Handle)data));
  121.             break;
  122.  
  123.         case HWRITEMESSAGE:
  124.             return(HWriteTreeObjData(hndl, (Handle)data));
  125.             break;
  126.  
  127.         case VHMESSAGE:
  128. #if VH_VERSION
  129.             cptr = ((VHFormatDataPtr)data)->data;
  130.             ccatchr(cptr, 13, 2);
  131.             VHRootInfo(hndl, cptr);
  132.             ccatchr(cptr, 13, 2);
  133.             VHFileRecInfo(hndl, cptr);
  134.             return(true);
  135. #endif
  136.             break;
  137.  
  138.         default:
  139.             break;
  140.     }
  141.  
  142.     return(noErr);
  143. }
  144.  
  145.  
  146.  
  147.